*****Note: Commands below need to be run before all moving window analyses****
tsset countrycode year, yearly
encode rrerclassification, generate(erregimecode)
replace erregimecode=0 if erregimecode==3
replace erregimecode=0 if erregimecode==1
encode erregime, generate(erregimecodeimf)
replace erregimecodeimf=0 if erregimecodeimf==3
replace erregimecodeimf=0 if erregimecodeimf==1
replace erregimecodeimf=0 if erregimecodeimf==5
generate erchange = ((nominaleffectiveexchangerate-L1.nominaleffectiveexchangerate)/L1.nominaleffectiveexchangerate)*100
generate govdeficit = -fiscalbalancepcofgdp

**NOTE SPREADS ARE THE DV BECAUSE IN CONTRAST TO BOND YIELDS THEY ARE STATIONARY
xtunitroot fisher nominallongterminterestrate, dfuller lags(0)
xtunitroot fisher spreadlongterminterestrates, dfuller lags(0)


*********************************************************************************
*********************************************************************************
**************************RESULTS FOR MAIN TABLES IN TEXT************************
*********************************************************************************
*********************************************************************************


*********************************************************************************
**INFLATION 

**Using I, R & R classification

local inflation "spreadlongterminterestrates d.unemployment realgdpgrowth currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.inflation L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.inflation"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `inflation' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])) (_b[`keyvariable']), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3])
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure 3a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Inflation") ycommon legendfrom(mu.gph)

clear

**Using IMF classification

local inflation "spreadlongterminterestrates d.unemployment realgdpgrowth currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.inflation L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.inflation"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `inflation' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3])
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure 3b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Inflation") ycommon legendfrom(mu.gph)

clear


****************************************************************************
**DEBT 


**Using I, R & R classification

local government_debt "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.governmentdebtpcofgdp"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_debt' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}
 
**For Figure 4a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Debt") ycommon legendfrom(mu.gph) 

clear


**Using IMF classification

local government_debt "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.governmentdebtpcofgdp"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_debt' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}
 
**For Figure 4b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Debt") ycommon legendfrom(mu.gph) 

clear


****************************************************************************
**DEFICIT 

**Using I, R & R classification

local government_deficit "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.govdeficit i.countrycode i.year"

local keyvariable "L1.govdeficit"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_deficit' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure 5a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Deficit") ycommon legendfrom(mu.gph) 

clear


**Using IMF classification

local government_deficit "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.govdeficit i.countrycode i.year"

local keyvariable "L1.govdeficit"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_deficit' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure 5b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Deficit") ycommon legendfrom(mu.gph) 

clear



****************************************************************************
****************************ROBUSTNESS CHECKS*******************************
****************************************************************************

*****************************************************************************
****************************************************************************
***APPENDIX C: Controlling for exchange rate movements (and a 1 year lead)**
****************************************************************************
*****************************************************************************

****************************************************************************
**INFLATION 

**Using I, R & R classification

local inflation "spreadlongterminterestrates d.unemployment realgdpgrowth currentaccountbalancepcofgdp erchange f.erchange election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.inflation L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.inflation"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `inflation' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])) (_b[`keyvariable']), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3])
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure C_1a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Inflation") ycommon legendfrom(mu.gph)

clear

**Using IMF classification

local inflation "spreadlongterminterestrates d.unemployment realgdpgrowth currentaccountbalancepcofgdp erchange f.erchange election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.inflation L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.inflation"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `inflation' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3])
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure C_1b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Inflation") ycommon legendfrom(mu.gph)

clear


****************************************************************************
**DEBT

**Using I, R & R classification

local government_debt "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp erchange f.erchange election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.governmentdebtpcofgdp"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_debt' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}
 
**For Figure C_2a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Debt") ycommon legendfrom(mu.gph) 

clear


**Using IMF classification

local government_debt "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp erchange f.erchange election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.governmentdebtpcofgdp"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_debt' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}
 
**For Figure C_2b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Debt") ycommon legendfrom(mu.gph) 

clear


****************************************************************************
**DEFICIT 


**Using I, R & R classification

local government_deficit "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation erchange f.erchange currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.govdeficit i.countrycode i.year"

local keyvariable "L1.govdeficit"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_deficit' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure C_3a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Deficit") ycommon legendfrom(mu.gph) 

clear


**Using IMF classification

local government_deficit "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation erchange f.erchange currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.govdeficit i.countrycode i.year"

local keyvariable "L1.govdeficit"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_deficit' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure C_3b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Deficit") ycommon legendfrom(mu.gph) 

clear



*****************************************************************************
*******************************************************************************
***APPENDIX E: Excluding EMU's most highly indebted countries (BE, GR and IT)**
*******************************************************************************
*****************************************************************************

tsset countrycode year, yearly
encode rrerclassification, generate(erregimecode)
replace erregimecode=0 if erregimecode==3
replace erregimecode=0 if erregimecode==1
encode erregime, generate(erregimecodeimf)
replace erregimecodeimf=0 if erregimecodeimf==3
replace erregimecodeimf=0 if erregimecodeimf==1
replace erregimecodeimf=0 if erregimecodeimf==5
generate erchange = ((nominaleffectiveexchangerate-L1.nominaleffectiveexchangerate)/L1.nominaleffectiveexchangerate)*100
generate govdeficit = -fiscalbalancepcofgdp
drop if countrycode==3
drop if countrycode==9
drop if countrycode==12

********************************************************************************
**INFLATION 

**Using I, R & R classification

local inflation "spreadlongterminterestrates d.unemployment realgdpgrowth currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.inflation L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.inflation"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `inflation' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])) (_b[`keyvariable']), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3])
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure E_1a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Inflation") ycommon legendfrom(mu.gph)

clear

**Using IMF classification

local inflation "spreadlongterminterestrates d.unemployment realgdpgrowth currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.inflation L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.inflation"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `inflation' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3])
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure E_1b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Inflation") ycommon legendfrom(mu.gph)

clear


****************************************************************************
**DEBT 

**Using I, R & R classification

local government_debt "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.governmentdebtpcofgdp"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_debt' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}
 
**For Figure E_2a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Debt") ycommon legendfrom(mu.gph) 

clear


**Using IMF classification

local government_debt "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.governmentdebtpcofgdp"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_debt' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}
 
**For Figure E_2b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Debt") ycommon legendfrom(mu.gph) 

clear


****************************************************************************
**DEFICIT 

**Using I, R & R classification

local government_deficit "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.govdeficit i.countrycode i.year"

local keyvariable "L1.govdeficit"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_deficit' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure E_3a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Deficit") ycommon legendfrom(mu.gph) 

clear


**Using IMF classification

local government_deficit "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.govdeficit i.countrycode i.year"

local keyvariable "L1.govdeficit"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_deficit' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure E_3b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Deficit") ycommon legendfrom(mu.gph) 

clear


*****************************************************************************
****************************************************************************
***APPENDIX F: Excluding EMU's lowest rated countries (GR, IT and PT)*******
****************************************************************************
*****************************************************************************

tsset countrycode year, yearly
encode rrerclassification, generate(erregimecode)
replace erregimecode=0 if erregimecode==3
replace erregimecode=0 if erregimecode==1
encode erregime, generate(erregimecodeimf)
replace erregimecodeimf=0 if erregimecodeimf==3
replace erregimecodeimf=0 if erregimecodeimf==1
replace erregimecodeimf=0 if erregimecodeimf==5
generate erchange = ((nominaleffectiveexchangerate-L1.nominaleffectiveexchangerate)/L1.nominaleffectiveexchangerate)*100
generate govdeficit = -fiscalbalancepcofgdp
drop if countrycode==9
drop if countrycode==12
drop if countrycode==18

*****************************************************************************
**INFLATION 

**Using I, R & R classification

local inflation "spreadlongterminterestrates d.unemployment realgdpgrowth currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.inflation L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.inflation"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `inflation' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])) (_b[`keyvariable']), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3])
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure F_1a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Inflation") ycommon legendfrom(mu.gph)

clear

**Using IMF classification

local inflation "spreadlongterminterestrates d.unemployment realgdpgrowth currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.inflation L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.inflation"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `inflation' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3])
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure F_1b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Inflation") ycommon legendfrom(mu.gph)

clear



****************************************************************************
**DEBT 

**Using I, R & R classification

local government_debt "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.governmentdebtpcofgdp"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_debt' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}
 
**For Figure F_2a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Debt") ycommon legendfrom(mu.gph) 

clear


**Using IMF classification

local government_debt "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.governmentdebtpcofgdp i.countrycode i.year"

local keyvariable "L1.governmentdebtpcofgdp"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_debt' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}
 
**For Figure F_2b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(3)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Debt") ycommon legendfrom(mu.gph) 

clear


****************************************************************************
**DEFICIT 

**Using I, R & R classification

local government_deficit "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecode##c.L1.govdeficit i.countrycode i.year"

local keyvariable "L1.govdeficit"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_deficit' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecode#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecode#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure F_3a

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Deficit") ycommon legendfrom(mu.gph) 

clear


**Using IMF classification

local government_deficit "spreadlongterminterestrates d.unemployment realgdpgrowth L1.inflation currentaccountbalancepcofgdp election_yn centercabinetseats leftcabinetseats concentrationofpower i.erregimecodeimf##c.L1.govdeficit i.countrycode i.year"

local keyvariable "L1.govdeficit"

local model "dataset"

tempname memhold
postfile `memhold' year b_mu se_mu b_flex se_flex b_fixed se_fixed using `model'.dta, replace
forvalues n = 1999(1)2017{
local g = `n' - 19
xtreg `government_deficit' i.year if inrange(year,`g',`n'), vce(cluster countrycode)
nlcom (_b[`keyvariable']+(_b[4.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[0.erregimecodeimf#c.`keyvariable'])) (_b[`keyvariable']+(_b[2.erregimecodeimf#c.`keyvariable'])), post
post `memhold' (`n') (_b[_nl_1]) (_se[_nl_1]) (_b[_nl_2]) (_se[_nl_2]) (_b[_nl_3]) (_se[_nl_3]) 
}
postclose `memhold'

use `model'.dta, clear
local exregimes "mu flex fixed"
foreach var of local exregimes{
gen ub`var' = b_`var' + 1.96* se_`var'
}
foreach var of local exregimes{
gen lb`var' = b_`var' - 1.96* se_`var'
}

**For Figure F_3b

twoway(rcap ubmu lbmu year, saving(mu.gph, replace) color(black) title("Monetary Union")) (connected  b_mu year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubflex lbflex year, saving(flex.gph, replace) color(black) title("Flexible Exchange Rates")) (connected  b_flex year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))
twoway(rcap ubfixed lbfixed year, saving(fixed.gph, replace) color(black) title("Fixed Peg Exchange Rates")) (connected  b_fixed year, yline(0)  xtitle("year") xlabel(1998(4)2017) ytitle("marginal effect on bond spreads") legend(label(1 "95% confidence interval") label(2 "marginal effect")))

grc1leg mu.gph flex.gph fixed.gph, title("Effect of Gov't Deficit") ycommon legendfrom(mu.gph) 

clear
